import store from '@/store/index'
import quinn from '@/utils/quinn'
import {IMG_HOST} from '@/assets/js/define.js'
import {
    _h,
    AFTERSALE_TAG,
    areaColumn,
    colorBlue,
    colorGreen,
    colorGrey,
    colorOrange,
    colorRed,
    createdColumn,
    EXTRA_ORDER_STATUS,
    EXTRA_ORDER_TAG_STATUS,
    EXTRA_TAG,
    FINANCE_TYPE_STATUS,
    FINANCE_TYPE_TAG_STATUS,
    goodsFeeColumn,
    hotelFeeColumn,
    INOUT_STATUS,
    INOUT_TAG_STATUS,
    installFeeColumn,
    inventoryColumn,
    ORDER_STATUS,
    ORDER_TAG_STATUS,
    otherFeeColumn,
    PRODUCT_STATUS,
    sortIndex,
    statusRender,
    statusRenderMap,
    trafficFeeColumn,
    updatedColumn,
    widthdf,
    widthlg,
    widthsm,
    widthssl,
    widthxl,
    widthxs,
    widthxsl,
    widthxxl,
} from './params'
import {fixed} from 'lodash/fp/_falseOptions'

const {authorityList = []} = quinn.getStorage('userData') || {}

const {userName = []} = quinn.getStorage('userData') || {}
const getOrderColumns = () => {
    let res = []
    if (authorityList.includes(105))
        res = [
            {
                label: '成本价',
                prop: 'costPrice',
                fixed: 'right',
                minWidth: widthdf,
            },
            {label: '利润', prop: 'profit', fixed: 'right', minWidth: widthdf},
        ]
    return res
}

const _imgRender = function (h, scope) {
    const {column, row} = scope
    const value = row[column.property]
    let imgList = []
    if (Array.isArray(value)) {
        try {
            imgList = value.filter((e) => e).map((e) => IMG_HOST + e)
        } catch (e) {
        }
    } else if ((value || '').includes(','))
        imgList = value
            .split(',')
            .filter((e) => e)
            .map((e) => IMG_HOST + e)
    else if (value) imgList.push(IMG_HOST + value)
    return imgList.length
        ? h(
            'el-image',
            {
                props: {
                    src: 'https://qiniushelves.jiachuangnet.com/shelf/img/%E6%9F%A5%E7%9C%8B%E8%AF%A6%E6%83%85.png',
                    fit: 'cover',
                    previewSrcList: imgList,
                },
                style: {
                    width: '55px',
                    height: '30px',
                },
            },
            {}
        )
        : h('div', {}, '-')
}
const _imgRenders = function (h, scope) {
    const {column, row} = scope
    const value = row[column.property]
    let imgList = []
    if (Array.isArray(value)) {
        try {
            imgList = value.filter((e) => e).map((e) => IMG_HOST + e)
        } catch (e) {
        }
    } else if ((value || '').includes(','))
        imgList = value
            .split(',')
            .filter((e) => e)
            .map((e) => IMG_HOST + e)
    else if (value) imgList.push(IMG_HOST + value)
    return imgList.length
        ? h(
            'el-image',
            {
                props: {
                    src: imgList.toString(),
                    fit: 'cover',
                    previewSrcList: imgList,
                },
                style: {
                    width: '55px',
                    height: '30px',
                },
            },
            {}
        )
        : h('div', {}, '-')
}

export const PaymentList = [
    // sortIndex,
    {label: '订单ID', prop: 'orderId', minWidth: widthssl},
    {label: '回款金额', prop: 'amount', minWidth: widthssl},
    // {
    //   label: '回款截图',
    //   prop: 'prove',
    //   minWidth: widthdf,
    //   fixed: 'right',
    //   render: _imgRender,
    // },
]

const commonOrder = [
    // sortIndex,
    {
        label: '类型',
        prop: 'orderTYpe',
        // fixed:'left',
        minWidth: '60px',
        render: function (h, scope) {
            const {column, row} = scope
            return h(
                'div',
                {
                    style: {
                        color: row.orderType == 2 ? colorOrange : colorBlue,
                    },
                },
                row.orderType == 2 ? '老店升级' : '新增店铺'
            )
        },
    },
    // {
    //     label: "",
    //     prop: "isPerSale",
    //     minWidth: '60px',
    //     render: function (h, scope) {
    //         const { row } = scope;
    //         let text = '';
    //         let color = '';
    //
    //         switch (row.isPerSale) {
    //             case 2:
    //                 text = '正式单';
    //                 color = colorOrange;
    //                 break;
    //             case 1:
    //                 text = '预售单';
    //                 color = colorBlue;
    //                 break;
    //             case 0:
    //             default:
    //                 text = '';
    //                 color = '#999'; // 默认灰色
    //         }
    //
    //         return h("div", {
    //             style: {
    //                 color: color
    //             }
    //         }, text);
    //     },
    // },
    {
        label: '订单状态',
        prop: 'lockInventory',
        // fixed:'left',
        minWidth: '60px',
        render: function (h, scope) {
            const {column, row} = scope
            return h(
                'div',
                {
                    style: {
                        color: row.lockInventory == 2 ? colorBlue : colorOrange,
                    },
                },
                row.lockInventory == 2 ? '已确认' : '未确认'
            )
        },
    },
    {
        label: '是否欠款',
        prop: 'isDebt',
        minWidth: '60px',
        render: function (h, scope) {
            const {column, row} = scope
            const actions = []
            if (row.isDebt == 0 || !row.isDebt)
                actions.unshift(
                    _h.call(
                        this,
                        h,
                        row.isDebt == 1 ? colorBlue : colorOrange,
                        'getIsDebt',
                        row.isDebt == 1 ? '已结清' : '欠款'
                    )
                )
            else actions.unshift(row.isDebt == 1 ? '已结清' : '欠款')
            return h('div', actions)
        },
    },
    {
        label: '卡游层板',
        prop: 'isKaYou',
        // fixed:'left',
        minWidth: '60px',
        render: function (h, scope) {
            const {column, row} = scope
            return h(
                'div',
                {
                    style: {
                        color: row.isKaYou == 1 ? colorBlue : colorOrange,
                    },
                },
                row.isKaYou == 1 ? '是' : '否'
            )
        },
    },
    {
        label: 'ID',
        prop: 'id',
        minWidth: '60px',
        render: function (h, scope) {
            const {column, row} = scope
            return h('div', {}, row?.orderId || row[column.property])
        },
    },
    {label: '订单名称', prop: 'storeName', minWidth: '100px'},
    {label: '所属品牌', prop: 'systemName', minWidth: '100px'},
    // {
    //     label: "所属品牌",
    //     prop: "systemType",
    //     // fixed:'left',
    //     minWidth: '80px',
    //     render: function (h, scope) {
    //         const {column, row} = scope;
    //         const value = row[column.property];
    //         const systemTypeMap = {
    //             1: "零食很忙",
    //             2: "零食优选",
    //             3: "卡游",
    //         };
    //         return h("div", {
    //             style: {
    //                 color: value ? (value == 1 ? colorBlue : colorOrange) : colorGrey,
    //             },
    //         }, systemTypeMap[value]);
    //     },
    // },
    {label: '发起人', prop: 'creatorName', minWidth: '60px'},
    {label: '发货日期', prop: 'deliveryDate', minWidth: '82px'},
    {label: '发货地址', prop: 'address', minWidth: '120px'},
    {label: '距离/公里', prop: 'distance', minWidth: '120px'},
    {label: '面积/平方', prop: 'storeArea', minWidth: '120px'},
    {
        label: '总成本/元',
        prop: 'id',
        minWidth: '150px',
        render: function (h, scope) {
            const {column, row} = scope
            const actions = [
                _h.call(
                    this,
                    h,
                    colorGrey,
                    '1',
                    '安装(含距离)：' + (row.installationCost || 0)
                ),
                _h.call(this, h, colorGrey, '2', '拣货：' + (row.jhCost || 0)),
                _h.call(this, h, colorGrey, '3', '装车：' + (row.zcCost || 0)),
                _h.call(this, h, colorGrey, '4', '距离：' + (row.distanceCost || 0)),
                _h.call(this, h, colorGrey, '5', '卸车：' + (row.xcCost || 0)),
                _h.call(this, h, colorBlue, '6', '总提成：' + (row.totalCost || 0)),
            ]
            return h(
                'div',
                {
                    style: {
                        display: 'flex',
                        flexWrap: 'wrap',
                    },
                },
                actions
            )
        },
    },
    {
        label: '付款明细',
        prop: 'id',
        minWidth: '150px',
        render: function (h, scope) {
            const {column, row} = scope
            const actions = [
                _h.call(this, h, colorGrey, '3', '付款金额:' + (row.payCount || '')),
                _h.call(this, h, colorGrey, '2', '付款卡号:' + (row.payCard || '')),
                _h.call(this, h, colorGrey, '1', '付款时间:' + (row.payTime || '')),
            ]
            return h(
                'div',
                {
                    style: {
                        display: 'flex',
                        flexWrap: 'wrap',
                    },
                },
                actions
            )
        },
    },
    {label: '客户联系方式', prop: 'customPhone', minWidth: '100px'},
    {label: '报价单运费', prop: 'expressCharge', minWidth: '100px'},
    createdColumn,
    ...(authorityList.includes(294)
        ? [{label: '应收金额', prop: 'totalAmount', minWidth: widthxs}]
        : []),
    ...(authorityList.includes(293)
        ? [{label: '已回款总额', prop: 'totalPayment', minWidth: '70px'}]
        : []),
    // {
    //   label: "省份",
    //   prop: "area",
    //   minWidth: "60px",
    //   render: function (h, scope) {
    //     const { column, row } = scope;
    //     const value = row[column.property];
    //     const { areaMap } = {
    //       43: "宁乡壹",
    //       42: "湖北",
    //       45: "广西",
    //       44: "广东",
    //       52: "贵州",
    //       53: '云南',
    //       46: "宁乡贰",
    //     };
    //     return h("div", {}, areaMap[value] || "-");
    //   },
    // },
    {
        label: '区域',
        prop: 'area',
        minWidth: '60px',
        render: function (h, scope) {
            const {column, row} = scope
            const value = row[column.property]
            return h('div', this.$store.state.areaMap[value] || '--')
        },
    },
    {
        label: '出库状态',
        prop: 'outStatus',
        minWidth: '70px',
        render: function (h, scope) {
            const {column, row} = scope
            const value = row[column.property]
            const outMap = {
                0: '待出库',
                1: '部分出库',
                2: '全部出库',
            }
            return h(
                'div',
                {
                    style: {
                        color: value ? (value == 1 ? colorBlue : colorOrange) : colorGrey,
                    },
                },
                outMap[value]
            )
        },
    },
    {
        label: '营业区原始图',
        prop: 'storeImgs',
        minWidth: '65px',
        render: _imgRender,
    },
    {
        label: '营业区转化图',
        prop: 'cadImg',
        minWidth: '65px',
        render: _imgRender,
    },
    {
        label: '仓库原始图',
        prop: 'storageOriginImg',
        minWidth: '65px',
        render: _imgRender,
    },
    {
        label: '仓库转化图',
        prop: 'storageImg',
        minWidth: '65px',
        render: _imgRender,
    },
    {
        label: '营业区报价图',
        prop: 'goodsOfferImg',
        minWidth: '65px',
        render: _imgRender,
    },
    {
        label: '仓储区报价图',
        prop: 'storageOfferImg',
        minWidth: '65px',
        render: _imgRender,
    },
]

const commonOrderFilter = (
    arr = [
        'sortIndex',
        'id',
        'storeName',
        'deliveryDate',
        'address',
        'customPhone',
        'createdTime',
        'orderType',
    ]
) => {
    return commonOrder.filter((e) => arr.includes(e.prop))
}

export const ClassifyDetail = [
    sortIndex,
    {label: '套件编码', prop: 'code', minWidth: widthxsl},
    {label: '套件名称', prop: 'name', minWidth: widthxsl},
    {label: '套件数量', prop: 'count', minWidth: widthxsl},
]

export const StoreLedger = [
    {label: 'ID', prop: 'id', minWidth: widthdf},
    {label: '订单ID', prop: 'orderId', minWidth: widthdf},
    {label: '门店名称', prop: 'storeName', minWidth: widthdf},
    {
        label: '状态',
        prop: 'status',
        fixed: 'right',
        minWidth: widthdf,
        render: statusRenderMap({
            0: ['未完成', 'danger'],
            1: ['已完成', 'success'],
        }),
    },
    {
        label: '操作',
        prop: 'actions',
        minWidth: '150px',
        // fixed: "right",
        render: function (h, scope) {
            const {column, row} = scope
            const status = row.status
            const actions = []
            if (status != 1)
                actions.push(_h.call(this, h, colorGreen, 'Done', '确认完成'))
            return h(
                'div',
                {
                    style: {
                        display: 'flex',
                        flexWrap: 'wrap',
                    },
                },
                actions
            )
        },
    },
]

export const AreaLedger = [
    {label: 'ID', prop: 'id', minWidth: widthdf},
    {
        label: '省份',
        prop: 'area',
        minWidth: widthdf,
        render: function (h, scope) {
            const {column, row} = scope
            const value = row[column.property]
            const {areaMap} = store.state
            return h('div', {}, areaMap[value] || '-')
        },
    },
    {label: '金额', prop: 'amount', minWidth: widthdf},
    {label: '费用类型', prop: 'type', minWidth: widthdf},
    // { label: "备注", prop: "remark", minWidth: widthxsl },
    {label: '图片', prop: 'imgs', minWidth: widthxsl, render: _imgRender},
    createdColumn,
    updatedColumn,
]

export const OrderAftersale = [
    ...commonOrderFilter(),
    {
        label: '售后原因',
        prop: 'afterSaleTypeText',
        minWidth: '240px',
    },
    {
        label: '售后备注',
        prop: 'remark',
        minWidth: '280px',
    },
    {
        label: '售后图片',
        prop: 'preSalesImg',
        minWidth: widthdf,
        render: _imgRender,
    },
    {label: '售后人员', prop: 'afterSales', minWidth: widthxl},
    {
        label: '售后完成备注',
        prop: 'finishRemark',
        minWidth: widthxl,
    },
    // {
    //   label: "售后完成图片",
    //   prop: "afterSalesImg",
    //   minWidth: widthdf,
    //   render: _imgRender,
    // },
    // { label: "发车金额", prop: "departFee", minWidth: widthxsl },
    // {
    //   label: "发车金额截图",
    //   prop: "departImg",
    //   minWidth: widthdf,
    //   render: _imgRender,
    // },
    // { label: "安装费用", prop: "installFee", minWidth: widthxsl },
    // {
    //   label: "安装费用截图",
    //   prop: "installImg",
    //   minWidth: widthdf,
    //   render: _imgRender,
    // },
    // { label: "安装住宿费用", prop: "hotelFee", minWidth: widthxsl },
    // {
    //   label: "安装住宿费用截图",
    //   prop: "hotelImg",
    //   minWidth: widthxl,
    //   render: _imgRender,
    // },
    // { label: "工作餐费用", prop: "foodFee", minWidth: widthxsl },
    // {
    //   label: "工作餐费用截图",
    //   prop: "foodImg",
    //   minWidth: widthdf,
    //   render: _imgRender,
    // },
    // { label: "交通费用", prop: "trafficFee", minWidth: widthxsl },
    // {
    //   label: "交通费用截图",
    //   prop: "trafficImg",
    //   minWidth: widthdf,
    //   render: _imgRender,
    // },
    {
        label: '状态',
        prop: 'status',
        minWidth: widthdf,
        fixed: 'right',
        render: statusRender(AFTERSALE_TAG),
    },
    {
        label: '操作',
        prop: 'actions',
        // fixed: "right",
        minWidth: widthxxl,
        render: function (h, scope) {
            const {column, row} = scope
            const status = row.status
            const actions = [_h.call(this, h, colorGrey, 'detail', '产品详情')]
            if (status == 0 && authorityList.includes(295))
                actions.unshift(_h.call(this, h, colorGreen, 'done', '确认完成'))
            if (authorityList.includes(179))
                actions.push(_h.call(this, h, colorRed, 'delete', '删除'))
            return h('div', {}, actions)
        },
    },
]

export const AdditionList = [
    sortIndex,
    {label: '产品ID', prop: 'id', minWidth: widthxl},
    {label: '产品编码', prop: 'productCode', minWidth: widthdf},
    {label: '产品名称', prop: 'productName', minWidth: widthxsl},
    {label: '规格', prop: 'norms', minWidth: widthdf},
    {label: '单位', prop: 'unit', minWidth: widthdf},
    {label: '颜色', prop: 'colour', minWidth: widthdf},
    // { label: "单价", prop: "price", minWidth: widthdf },
    {label: '数量', prop: 'count', minWidth: widthdf, fixed: 'right'},
]

export const AfterSaleDetail = AdditionList

export const InstallList = [
    sortIndex,
    {label: '安装人员', prop: 'installers', minWidth: widthxl},
    // { label: "发车金额", prop: "departFee", minWidth: widthxsl },
    // {
    //   label: "发车金额截图",
    //   prop: "departImg",
    //   minWidth: widthdf,
    //   render: _imgRender,
    // },
    // { label: "安装费用", prop: "installFee", minWidth: widthxsl },
    // {
    //   label: "安装费用截图",
    //   prop: "installImg",
    //   minWidth: widthdf,
    //   render: _imgRender,
    // },
    // { label: "安装住宿费用", prop: "hotelFee", minWidth: widthxsl },
    // {
    //   label: "安装住宿费用截图",
    //   prop: "hotelImg",
    //   minWidth: widthdf,
    //   render: _imgRender,
    // },
    // { label: "工作餐费用", prop: "foodFee", minWidth: widthxsl },
    // {
    //   label: "工作餐费用截图",
    //   prop: "foodImg",
    //   minWidth: widthdf,
    //   render: _imgRender,
    // },
    // { label: "交通费用", prop: "trafficFee", minWidth: widthxsl },
    // {
    //   label: "交通费用截图",
    //   prop: "trafficImg",
    //   minWidth: widthdf,
    //   render: _imgRender,
    // },
]

export const OrderExtra = [
    sortIndex,
    // { label: "订单ID", prop: "id", minWidth: widthxxl },
    // { label: "订单名称", prop: "orderName", minWidth: widthxsl },
    {label: '售后金额', prop: 'fee', minWidth: widthdf},
    {
        label: '售后理由',
        prop: 'reason',
        minWidth: widthxsl,
        render: statusRender(EXTRA_TAG),
    },
    {label: '售后备注', prop: 'remark', minWidth: widthxsl, showTip: true},
    {label: '创建人', prop: 'creatorName', minWidth: widthdf},
    createdColumn,
    // updatedColumn,
    {
        label: '订单状态',
        prop: 'status',
        minWidth: widthsm,
        fixed: 'right',
        render: statusRender(EXTRA_ORDER_STATUS, EXTRA_ORDER_TAG_STATUS),
    },
    {
        label: '操作',
        prop: 'actions',
        // fixed: "right",
        minWidth: widthxxl,
        render: function (h, scope) {
            const {column, row} = scope
            const status = row.status
            const actions = [_h.call(this, h, colorGrey, '0', '查看产品')]
            if (status == 0) {
                actions.unshift(
                    _h.call(this, h, colorRed, '-1', '拒绝'),
                    _h.call(this, h, colorGreen, '1', '通过')
                )
            }
            return h('div', {}, actions)
        },
    },
]

export const ExbandColumn = [
    sortIndex,
    {label: '订单ID', prop: 'id', minWidth: widthxxl},
    {label: '订单名称', prop: 'orderName', minWidth: widthxsl},
    {label: '售后金额', prop: 'fee', minWidth: widthdf},
    {
        label: '售后理由',
        prop: 'reason',
        minWidth: widthxsl,
        render: statusRender(EXTRA_TAG),
    },
    {label: '售后备注', prop: 'remark', minWidth: widthxsl, showTip: true},
    {label: '创建人', prop: 'creatorName', minWidth: widthdf},
    createdColumn,
    // updatedColumn,
    {
        label: '订单状态',
        prop: 'status',
        minWidth: widthsm,
        render: statusRender(EXTRA_ORDER_STATUS, EXTRA_ORDER_TAG_STATUS),
    },
]

export const OrderInstall = [
    sortIndex,
    {label: '订单ID', prop: 'id', minWidth: widthxxl},
    {label: '订单名称', prop: 'orderName', minWidth: widthxsl},
    goodsFeeColumn,
    installFeeColumn,
    hotelFeeColumn,
    trafficFeeColumn,
    otherFeeColumn,
    {
        label: '报装人',
        prop: 'installers',
        minWidth: widthdf,
        render: function (h, scope) {
            const {column, row} = scope
            return h('span', {}, row[column.property].join('、'))
        },
    },
    {label: '报装备注', prop: 'description', minWidth: widthxsl, showTip: true},
    {label: '创建人', prop: 'creatorName', minWidth: widthdf},
    createdColumn,
    // updatedColumn,
]

export const OrderFlow = [
    sortIndex,
    {label: '订单编号', prop: 'orderId', minWidth: widthxxl},
    {label: '订单名称', prop: 'orderName', minWidth: widthxsl},
    {label: '创建人', prop: 'creatorName', minWidth: widthdf},
    createdColumn,
    // updatedColumn,
    {
        label: '订单状态',
        prop: 'status',
        minWidth: widthsm,
        fixed: 'right',
        render: statusRender(ORDER_STATUS, ORDER_TAG_STATUS),
    },
]

export const InventoryWarn = [
    sortIndex,
    areaColumn,
    {label: '产品编码', prop: 'productCode', minWidth: widthdf},
    {label: '产品名称', prop: 'productName', minWidth: widthxsl},
    // { label: "套件", prop: "dirName", minWidth: widthxsl },
    {label: '规格', prop: 'norms', minWidth: widthdf},
    {label: '单位', prop: 'unit', minWidth: widthdf},
    {label: '颜色', prop: 'colour', minWidth: widthdf},
    // { label: '单价', prop: 'price', minWidth: widthdf },
    createdColumn,
    updatedColumn,
    inventoryColumn,
]

let saleKeys = []
let saleAction = [
    {
        label: '操作',
        prop: 'actions',
        minWidth: 100,
        // fixed: "right",
        render: function (h, scope) {
            const actions = []
            if (authorityList.includes(1253)) {
                actions.push(_h.call(this, h, colorGrey, 'modifyCount', '修改库存')) //仓库主管不可以修改库存
            }
            if (authorityList.includes(1252))
                actions.push(_h.call(this, h, colorBlue, 'modifyWarning', '修改预警值'))
            return h('div', {}, actions)
        },
    },
    // {
    //   label: "修改库位",
    //   prop: "editPosition",
    //   minWidth: widthdf,
    //   // fixed: "right",
    //   render: function (h, scope) {
    //     return _h.call(this, h, colorGreen, "modifyWarePosition", "修改库位");
    //   },
    // },
]
if ((authorityList || []).includes(191))
    saleKeys = [
        {label: '成本价', prop: 'price', minWidth: widthdf},
        {label: '售价', prop: 'salePrice', minWidth: widthdf},
    ]

if ((authorityList || []).includes(5)) saleAction = []

export const InventoryDetail = [
    sortIndex,
    areaColumn,
    // { label: "库位", prop: "warehousePosition", minWidth: widthdf },
    {label: '产品编码', prop: 'productCode', minWidth: widthdf},
    {label: '产品名称', prop: 'productName', minWidth: widthxsl},
    // { label: "套件", prop: "dirName", minWidth: widthxsl },
    // {
    //   label: "套件",
    //   prop: "directorys",
    //   minWidth: '200',
    //   render: function (h, scope) {
    //     const { column, row } = scope;
    //     const value = (row[column.property] || []).map((e) => e.name);
    //     let data = Ray.duplicate(value)
    //     return h("span", {}, data.join("、"));
    //   },
    // },
    {label: '规格', prop: 'norms', minWidth: widthdf},
    {label: '单位', prop: 'unit', minWidth: widthdf},
    {label: '颜色', prop: 'colour', minWidth: widthdf},
    {
        label: '预警值',
        prop: 'warningNum',
        minWidth: widthdf,
        render: function (h, scope) {
            const {column, row} = scope
            return h('div', (row.exigencyNum || 0) + '-' + row.warningNum)
        },
    },
    {
        label: '库存状态',
        prop: 'warningNum',
        minWidth: widthdf,
        render: function (h, scope) {
            const {column, row} = scope
            return h(
                'div',
                {
                    style: {
                        color:
                            row.stockStatus === 1
                                ? '#000000'
                                : row.stockStatus === 2
                                    ? colorOrange
                                    : row.stockStatus === 3
                                        ? colorRed
                                        : colorGreen,
                    },
                },
                row.stockStatus === 1
                    ? '正常'
                    : row.stockStatus === 2
                        ? '警告'
                        : row.stockStatus === 3
                            ? '紧急'
                            : '未知状态'
            )
        },
    },
    ...saleKeys,
    createdColumn,
    updatedColumn,
    inventoryColumn,
    ...saleAction,
]
export const ExtraListColumn = [
    sortIndex,
    {label: '产品ID', prop: 'id', minWidth: widthxl},
    {label: '产品编码', prop: 'productCode', minWidth: widthdf},
    {label: '产品名称', prop: 'productName', minWidth: widthxsl},
    {label: '规格', prop: 'norms', minWidth: widthdf},
    {label: '单位', prop: 'unit', minWidth: widthdf},
    {label: '颜色', prop: 'colour', minWidth: widthdf},
    // { label: '单价', prop: 'price', minWidth: widthdf },
    {label: '数量', prop: 'count', minWidth: widthdf, fixed: 'right'},
]

export const InventoryRecordDetail = [
    sortIndex,
    {label: '产品ID', prop: 'id', minWidth: widthxl},
    {label: '产品编码', prop: 'productCode', minWidth: widthdf},
    {label: '产品名称', prop: 'productName', minWidth: widthxsl},
    {label: '规格', prop: 'norms', minWidth: widthdf},
    {label: '单位', prop: 'unit', minWidth: widthdf},
    {label: '颜色', prop: 'colour', minWidth: widthdf},
    // { label: '单价', prop: 'price', minWidth: widthdf },
    {label: '数量', prop: 'count', minWidth: widthdf, fixed: 'right'},
]

export const ProductManage = [
    sortIndex,
    {label: '产品ID', prop: 'id', minWidth: widthxl},
    {label: '产品编码', prop: 'productCode', minWidth: widthdf},
    {label: '产品名称', prop: 'productName', minWidth: widthxsl},
    // {
    //   label: "套件",
    //   prop: "directorys",
    //   minWidth: widthxsl,
    //   render: function (h, scope) {
    //     const { column, row } = scope;
    //     const value = (row[column.property] || []).map((e) => e.name);
    //     let data = Ray.duplicate(value)
    //     return h("span", {}, data.join("、"));
    //   },
    // },
    {label: '规格', prop: 'norms', minWidth: widthdf},
    {label: '单位', prop: 'unit', minWidth: widthdf},
    {label: '颜色', prop: 'colour', minWidth: widthdf},
    // { label: '单价', prop: 'price', minWidth: widthdf },
    {label: '说明', prop: 'description', width: widthxsl, showTip: true},
    {label: '图片', prop: 'productImgStr', minWidth: widthxsl, render: _imgRenders},
    createdColumn,
    updatedColumn,
    {
        label: '状态',
        prop: 'materialStatus',
        minWidth: widthsm,
        fixed: 'right',
        render: statusRender(PRODUCT_STATUS),
    },
    {
        label: '操作',
        prop: 'actions',
        minWidth: '140px',
        // fixed: "right",
        render: function (h, scope) {
            const {column, row} = scope
            const status = row.materialStatus
            return h('div', {}, [
                _h.call(this, h),
                status == 0
                    ? _h.call(this, h, colorBlue, 'on', '上架')
                    : _h.call(this, h, colorOrange, 'off', '下架'),
                // _h.call(this, h, colorGreen, "qrcode", "库存码"),
                _h.call(this, h, colorRed, 'delete', '删除'),
            ])
        },
    },
]

export const InventoryRecord = [
    sortIndex,
    areaColumn,
    // { label: "产品编码", prop: "productCode", minWidth: widthdf },
    // { label: "产品名称", prop: "productName", minWidth: widthxsl },
    // { label: "套件", prop: "dirName", minWidth: widthdf },
    // { label: "规格", prop: "norms", minWidth: widthdf },
    // { label: "单位", prop: "unit", minWidth: widthdf },
    // { label: "颜色", prop: "colour", minWidth: widthdf },
    // { label: "单价", prop: "price", minWidth: widthdf },
    {label: '订单号', prop: 'orderId', minWidth: widthdf},
    {label: '门店名称', prop: 'storeName', minWidth: widthdf},
    {label: '拣货人员', prop: 'sorter', minWidth: widthdf},
    {label: '操作人', prop: 'creatorName', minWidth: widthxsl},
    createdColumn,
    updatedColumn,
    // {label: "采购单名", prop: "purchaseName", minWidth: widthxsl},
    {
        label: '采购单图',
        prop: 'pimg',
        minWidth: widthdf,
        render: _imgRenders,
    }, // inventoryColumn,
    {
        label: '发车照片',
        prop: 'deliveryImg',
        minWidth: widthdf,
        render: _imgRenders,
    },
    {
        label: '送货单图',
        prop: 'listImg',
        minWidth: widthdf,
        render: _imgRender,
    },
    {
        label: '状态',
        prop: 'status',
        minWidth: widthsm,
        fixed: 'right',
        render: statusRender(INOUT_STATUS, INOUT_TAG_STATUS),
    },
    {
        label: '操作',
        prop: 'actions',
        minWidth: '100px',
        // fixed: "right",
        render: function (h, scope) {
            const {column, row} = scope
            const status = row.status
            return h('div', {}, [
                status == 0
                    ? _h.call(this, h, colorGreen, 'detail', '出库清单')
                    : _h.call(this, h, colorBlue, 'detail', '入库清单'),
            ])
        },
    },
]

export const ClassifyManage = [
    sortIndex,
    {label: '套件名称', prop: 'name', minWidth: widthxsl},
    // { label: '套件价格', prop: 'salePrice', minWidth: widthxsl },
    {label: '创建人', prop: 'creatorName', minWidth: widthdf},
    createdColumn,
    updatedColumn,
    {
        label: '状态',
        prop: 'status',
        minWidth: widthsm,
        fixed: 'right',
        render: statusRender(),
    },
    {
        label: '操作',
        prop: 'actions',
        minWidth: widthlg,
        // fixed: "right",
        render: function (h, scope) {
            const {column, row} = scope
            const status = row.status
            return h('div', {}, [
                _h.call(this, h),
                // status == 0
                //   ? _h.call(this, h, colorBlue, "on", "开启")
                //   : _h.call(this, h, colorOrange, "off", "禁用"),
                _h.call(this, h, colorRed, 'delete', '删除'),
            ])
        },
    },
]

export const AccountManage = [
    sortIndex,
    {label: '姓名', prop: 'userName', minWidth: widthdf},
    {label: '手机号码', prop: 'mobile', minWidth: widthdf},
    {
        label: '角色',
        prop: 'role.name',
        minWidth: widthdf,
    },
    // { label: "上级", prop: "leaderName", minWidth: widthdf },
    createdColumn,
    updatedColumn,
    {
        label: '操作',
        prop: 'actions',
        // fixed: "right",
        minWidth: widthxxl,
        action: [
            {
                text: '修改',
                type: 'text',
                options: 'edit',
            },
            // {
            //   text: "修改密码",
            //   type: "text",
            //   options: "editPsd",
            //   style: {
            //     color: colorOrange,
            //   },
            // },
            {
                text: '删除',
                type: 'text',
                options: 'delete',
                style: {
                    color: colorRed,
                },
            },
        ],
    },
]

export const RoleManage = [
    {label: '角色ID', prop: 'id', minWidth: widthdf},
    {label: '角色权限', prop: 'permission', minWidth: widthdf},
    {label: '角色名', prop: 'name', minWidth: widthdf},
    {label: '角色描述', prop: 'description', minWidth: widthdf},
    createdColumn,
    updatedColumn,
    {
        label: '状态',
        prop: 'status',
        minWidth: widthsm,
        fixed: 'right',
        render: statusRender(),
    },
    {
        label: '操作',
        prop: '',
        // fixed: "right",
        action: [
            {
                text: '修改',
                type: 'text',
                options: 'edit',
            },
        ],
    },
]

export const Finance = [
    ...commonOrderFilter(),
    {label: '已支付总金额', prop: 'payAmount', minWidth: widthsm},
    {
        label: '付款凭证',
        prop: 'payVoucher',
        minWidth: widthdf,
        render: _imgRender,
    },
    {label: '驳回备注', prop: 'remark', width: widthssl},
    ...OrderAftersale.filter((e) =>
        [
            'departFee',
            'departImg',
            'installFee',
            'installImg',
            'hotelFee',
            'hotelImg',
            'foodFee',
            'foodImg',
            'trafficFee',
            'trafficImg',
        ].includes(e.prop)
    ),
    {
        label: '订单类型',
        prop: 'type',
        minWidth: widthsm,
        fixed: 'right',
        render: statusRender(FINANCE_TYPE_STATUS, FINANCE_TYPE_TAG_STATUS),
    },
    {
        label: '操作',
        prop: 'actions',
        minWidth: widthdf,
        // fixed: "right",
        render: function (h, scope) {
            const {column, row} = scope
            const status = row.status
            const actions = []
            if (authorityList.includes(184) && status == 0)
                actions.push(_h.call(this, h, colorBlue, 'financeDoneRef', '付款完成'))
            if (authorityList.includes(183) && status == 0)
                actions.push(
                    _h.call(this, h, colorOrange, 'finaceRefuseRef', '付款驳回')
                )
            if (authorityList.some((e) => [182, 181, 180].includes(e)))
                actions.push(_h.call(this, h, colorRed, 'delete', '删除'))
            return h(
                'div',
                {
                    style: {
                        display: 'flex',
                        flexWrap: 'wrap',
                    },
                },
                actions
            )
        },
    },
]

let newFinance = Finance.filter((e) => e.prop != 'actions')
newFinance.push({
    label: '操作',
    prop: 'actions',
    // fixed: "right",
    minWidth: widthsm,
    render: function (h, scope) {
        const {column, row} = scope
        const status = row.status
        const actions = []
        actions.push(_h.call(this, h, colorRed, 'updateFinanceRef', '编辑'))
        return h('div', {}, actions)
    },
})

export const FinanceReject = newFinance
